import {Injectable} from '@angular/core';


@Injectable()
export class UserService {

    constructor() {
    }

    get(users, nickname, userName) {
        if (users instanceof Array) {
            for (var i = 0; i < users.length; i++) {
                //主要使用 userName 判断
                if (users[i].nickname === nickname || users[i].userName === userName) {
                    return users[i];
                }
            }
        } else {
            return null;
        }
    }

    getID(users, ID) {
        if (users instanceof Array) {
            for (var i = 0; i < users.length; i++) {
                if (users[i].ID === ID) {
                    return users[i];
                }
            }
        } else {
            return null;
        }
    }

}
